package com.starleague.battletech.unit.mech.jpa.appengine;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToOne;

import com.starleague.battletech.unit.BattletechUnitInternalStructureType;
import com.starleague.battletech.unit.IWeight;
import com.starleague.battletech.unit.jpa.appengine.BattletechUnitInternalStructureGae;
import com.starleague.battletech.unit.mech.IMechInternalStructure;

@Entity(name = "MECH_INTERNAL_STRUCTURE")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class MechInternalStructureGae
        extends BattletechUnitInternalStructureGae
        implements IMechInternalStructure
{
    // Remember, AppEngine doesn't support FetchType.EAGER / Joins
    @OneToOne(mappedBy = "internalStructure", fetch = FetchType.LAZY, optional = false)
    private MechGae mech;

    MechInternalStructureGae(MechGae mech,
                             IWeight weight,
                             BattletechUnitInternalStructureType internalStructureType)
    {
        super(weight, internalStructureType);
        this.mech = mech;
    }

    protected MechInternalStructureGae()
    {
        //
    }

    @Override
    public MechGae getMech()
    {
        return this.mech;
    }

    // // TODO!
    // @Override
    // protected List<? extends BattletechUnitCriticalSlotGae> getCriticalSlots()
    // {
    // return ImmutableList.of();
    // }
}
